package com.generator.collet.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import java.io.*;
import java.nio.charset.Charset;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

/**
 * <p>
 * 班级大事件
 * </p>
 *
 * @author tiankun
 * @since 2023-06-09
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sch_event_eval")
public class SchEventEvalEntity extends Model<SchEventEvalEntity> {

    private static final long serialVersionUID=1L;

    /**
     * 唯一标识
     */
    private String evalId;

    /**
     * 学期标识
     */
    private String semesterId;

    /**
     * 学段标识
     */
    private String acaStage;

    /**
     * 学届标识
     */
    private String gradeId;

    private String curStage;

    /**
     * 班级标识
     */
    private String classId;

    /**
     * 事件名称
     */
    private String eventName;

    /**
     * 事件时间
     */
    private LocalDateTime eventTime;

    /**
     * 学生照片（逗号分隔）
     */
    private String studentPhotos;

    /**
     * 评语
     */
    private String comment;

    /**
     * 学校标识
     */
    private String schoolId;

    /**
     * 创建人
     */
    private String createUser;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 最后操作人
     */
    private String operateUser;

    /**
     * 最后操作时间
     */
    private LocalDateTime operateTime;


    @Override
    protected Serializable pkVal() {
        return this.evalId;
    }

    public static void main(String[] args) throws Exception{
            Map<String, Object> paramMap = new HashMap<>();
            DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
            paramMap.put("date_time", dateTimeFormatter.format(LocalDateTime.now()));
            paramMap.put("date", dateTimeFormatter.format(LocalDateTime.now()).substring(0, 10));
            String outPath = "D:\\Test.pdf";
            String templateDirectory = "D:\\";
//            String templateContent = getTemplateContent(templateDirectory, "pdftest_template.html", paramMap);
//            html2Pdf(templateContent, outPath);
    }


//    private static String getTemplateContent(String templateDirectory, String templateName, Map<String, Object> paramMap) throws Exception {
//        Configuration configuration = new Configuration(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS);
//        try {
//            configuration.setDirectoryForTemplateLoading(new File(templateDirectory));
//        } catch (Exception e) {
//            System.out.println("-- exception --");
//        }
//
//        Writer out = new StringWriter();
//        Template template = configuration.getTemplate(templateName,"UTF-8");
//        template.process(paramMap, out);
//        out.flush();
//        out.close();
//        return out.toString();
//    }
//
//    public static boolean html2Pdf(String content, String outPath) {
//        try {
//            Document document = new Document();
//            PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(outPath));
//            document.open();
//            XMLWorkerHelper.getInstance().parseXHtml(writer, document,
//                    new ByteArrayInputStream(content.getBytes()), null, Charset.forName("UTF-8"));
//            document.close();
//        } catch (Exception e) {
//            System.out.println("生成模板内容失败"+e.fillInStackTrace());
//            return false;
//        }
//        return true;
//    }


}
